import format from '@dfeidao/atom-web/dt/format';
import get from '@dfeidao/atom-web/global/get';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p002 from './p002';
import p003 from './p003';
interface Par extends Event {
	page_no: number;
}
export default async function a009(fd: IFeidaoAiBrowserComponent,e: Par) {
	// todo
	const staff_no = get('staff_no');
	const pdname = fd.data.node.querySelector<HTMLInputElement>('[data-id=pdname]').value;
	const xm = fd.data.node.querySelector<HTMLSelectElement>('[data-id=xm]').value;
	const res = await nodejs<{
		dt: Array<{
			lnventory_name: string, project_name: string,
			inventory_time: number, inventory_people: string, record_no: string
		}>; dt2: number
	}>('inventory-of-assets/zj-000001/s001', {
		pn:e.page_no,
		Inventory_people_no: staff_no,
		project_id: xm,
		lnventory_name: pdname
	});
	const tt = res.dt.map((n) => {
		return { ...n, inventory_time: format(n.inventory_time, 0) };
	});

	if (res.dt.length > 0) {
		render(fd, tt, p002, 'p002', 'inner');
	} else {
		render(fd, '', p003, 'p003', 'inner');
	}
}
